package day0520;

import java.util.Scanner;

public class Test12 {
    public static void main(String[] args) {
        String r=guess(100);
        System.out.println(r);
    }

    public static String guess(int max) {
        int n1=(int)(Math.random()*max);
        int i=1;
        do{
            int n2=new Scanner(System.in).nextInt();
            if(n1==n2){
                return "恭喜你猜对了，猜的次数为：" + i;
            }else if(n2>n1){
                System.out.println("猜大了");
            }else{
                System.out.println("猜小了");
            }
            if(n2==-1){
                return "即将退出程序，猜的次数为：" + i;
            }
            i++;
        }while(true);
    }
}
